package cn.com.winson.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

/**
 * 自定义登录拦截器
 * 
 * @author lvhao
 * @date 2018年12月8日
 * @time 上午10:14:37
 */
public class LoginInterceptor implements HandlerInterceptor {

	@Override
	public void afterCompletion(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, Exception arg3)
			throws Exception {

	}

	@Override
	public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, ModelAndView arg3)
			throws Exception {

	}
	
	/*在请求进入到controller之前会调用此方法，所以在该方法中编写拦截逻辑*/
	@Override
	public boolean preHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2) throws Exception {
		System.out.println("验证登录认证，并遵守拦截器规则，现在放行");
		/*这里省略了拦截器的逻辑设计，直接认证通过*/
		/*既然认证通过，返回值就为true，逻辑可以继续往下执行*/
		return true;
	}

}
